<template>
  <simple-select :data-list="userList" v-model="user" v-on="$listeners" v-bind="$attrs"  :filter-method="getSimpleAllUser"  filterable></simple-select>
</template>
<script>
  import api from "@/api/index";
  import SimpleSelect from './SimpleSelect'
  export default {
    name:"UserSelectSearch",
    components: { SimpleSelect },
    props:["value"],
    data(){
      return {
        userList:[]
      }
    },
    computed: {
      user: {
        get() {
          return this.value
        },
        set(v) {
          this.$emit('input', v)
        }
      }
    },
    methods:{
      getSimpleAllUser(data) {
        api.getAllSimpleUser({page: 1, per_page: 10, search_value: data}).then(res => {
          this.userList = res.data.value;
          this.userList.map(item=>{
            item.id = item.username
            item.name = item.username+"("+item.alias+")"
          })
        });
      },
    }
  }
</script>
